﻿using System;
using System.Web.UI.WebControls;
using BookingSystem.Services;

namespace OSDK.Bokning
{
    public partial class Booking : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
          btnClose.Attributes.Add("OnClick", "window.close();");

            if (!IsPostBack)
            {
                GetInParameters();
                LoadGuests();
            }
        }

        private void GetInParameters()
        {

            lblBookingNumber.Text = Page.Request.QueryString["BookingNumber"];

            if (lblBookingNumber.Text != string.Empty)
            {
                FillByBookingId(lblBookingNumber.Text);
                return;
            }

            lblStartDate.Text =  Page.Request.QueryString["StartDate"];
            lblEndDate.Text = Page.Request.QueryString["EndDate"];
            lblResource.Text = Page.Request.QueryString["Resource"];
            
        }

        private void FillByBookingId(string text)
        {
//            lblStartDate.Text = Page.Request.QueryString["StartDate"];
//            lblEndDate.Text = Page.Request.QueryString["EndDate"];
//            lblResource.Text = Page.Request.QueryString["Resource"];
            
        }

        private void LoadGuests()
        {
            var guestService = new GuestService();

            var guests = guestService.GetAll();

            foreach (var guest in guests)
            {
                ddlGuest.Items.Add(new ListItem(guest.Fullname(),guest.Id.ToString()));
            }
        }

        protected void btnSave_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {

        }
       
    }
}